function initialize()
{
	var address = '35 Phố huế hoàn kiếm hà nội';
	var geocoder, map;
	var markers = [], infoWindowList = [];
	var infowindow = null;

	codeAddress(address);

	function codeAddress(address) {

	    geocoder = new google.maps.Geocoder();
	    geocoder.geocode({
	        'address': address
	    }, 
	    function(results, status) {
	        if (status == google.maps.GeocoderStatus.OK) {
	        	var location = results[0].geometry.location;
	            var myOptions = {
	                center:location,
					zoom:16,
					panControl:false,
					zoomControl:true,
					mapTypeControl:false,
					scaleControl:false,
					streetViewControl:false,
					overviewMapControl:false,
					rotateControl:false,
				    zoomControlOptions: {
			      		style:google.maps.ZoomControlStyle.SMALL
				    },
					mapTypeId:google.maps.MapTypeId.ROADMAP
	            }

	            map = new google.maps.Map(document.getElementById("googleMap"), myOptions);

	            google.maps.event.addListener(map, 'click', function(event) {
				    addMarker(event.latLng);
			  	});

	           addMarker(location);
	        }
	    });
	}

	function addMarker(location) {
		var marker = new google.maps.Marker({
		    position: location,
		    map: map
		});

		markers.push(marker);
		string_conten = 'Latitude: ' + location.lat() + '<br>Longitude: ' + location.lng();

		google.maps.event.addListener(marker, 'click', function() {
			if (infowindow) {
		        infowindow.close();
		    }
			infowindow = new google.maps.InfoWindow({maxWidth:150});
	 		infowindow.setContent(string_conten);
			
	  		infowindow.open(map,marker);
	  	});

	}
}


function loadScript()
{
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyAgSi6dfpgY9uU9MqmgO6fKs3o1yXlF0I0&sensor=true&callback=initialize"; 
	document.body.appendChild(script);
}

window.onload = loadScript;
